var locat = (window.location + '').split('/');
$(function() {
	if ('main' == locat[3]) {
		locat = locat[0] + '//' + locat[2];
	} else {
		locat = locat[0] + '//' + locat[2] + '/' + locat[3];
	};
	set_catId_shen();
});

// 级联省
function set_catId_shen() {
	alert(locat + 'city/provinceTree.do?parentId=0');
	$('#catId_shen').combotree({
		url : locat + 'city/provinceTree.do?parentId=0',
		required : true,
		onSelect : function(data) {
			$("#catId").val(data.id);
			set_catId_shi(data.id);
			set_catId_qu(-1);
		},
		loadFilter : function(data, parent) {
			return data.rows;
		}
	});
}

// 级联市
function set_catId_shi(id) {
	$('#catId_shi').combotree({
		url : locat + 'city/provinceTree.do?parentId=' + id,
		onSelect : function(data) {
			$("#catId").val(data.id);
			set_catId_qu(data.id);
		},
		loadFilter : function(data, parent) {
			return data.rows;
		}
	});
}

// 级联区
function set_catId_qu(id) {
	$('#catId_qu').combotree({
		url : locat + 'city/provinceTree.do?parentId=' + id,
		onSelect : function(data) {
			$("#catId").val(data.id);
			set_catId_zheng(data.id);
		},
		loadFilter : function(data, parent) {
			return data.rows;
		}
	});
}

// 级联镇
function set_catId_zheng(id) {
	$('#catId_zheng').combotree({
		url : locat + 'city/provinceTree.do?parentId=' + id,
		onSelect : function(data) {
			$("#catId").val(data.id);
		},
		loadFilter : function(data, parent) {
			return data.rows;
		}
	});
}